JavaScript: A Beginner's Guide, Fourth Edition: A Beginner's Guide by John Pollock

JavaScript: A Beginner's Guide, Fourth Edition: A Beginner's Guide by John Pollock

Author:John Pollock [Pollock, John]
Language: eng
Format: mobi
Tags: -
Publisher: McGraw-Hill Education
Published: 2013-04-08T16:00:00+00:00


Here, the d1 element’s onclick property is assigned a function expression (refer to Chapter 4 if you need to review function expressions), which can then execute code. Thus, when the d1 element is clicked by the user, any code within the function will be executed.

So, you can now take the code you were using to change styles and perform the task when the user clicks the element rather than while the page is loading. The following code shows an example of this:

Figure 9-9 shows what the page looks like after the user clicks on the first div element. The background color has changed from white to a light gray.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.